home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-13 / thesrc10.zip / TRACE.C < prev    next >
C/C++ Source or Header  |  1992-08-04  |  3KB  |  94 lines

  1. /*
  2.  * THE - The Hessling Editor. A text editor similar to VM/CMS xedit.
  3.  * Copyright (C) 1991,1992 Mark Hessling
  4.  * 
  5.  * This program is free software; you can redistribute it and/or
  6.  * modify it under the terms of the GNU General Public License as
  7.  * published by the Free Software Foundation; either version 2 of
  8.  * the License, or any later version.
  9.  * 
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13.  * General Public License for more details.
  14.  * 
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to:
  17.  * 
  18.  *    The Free Software Foundation, Inc.
  19.  *    675 Mass Ave,
  20.  *    Cambridge, MA 02139 USA.
  21.  * 
  22.  * 
  23.  * If you make modifications to this software that you feel increases
  24.  * it usefulness for the rest of the community, please email the
  25.  * changes, enhancements, bug fixes as well as any and all ideas to me.
  26.  * This software is going to be maintained and enhanced as deemed 
  27.  * necessary by the community.
  28.  *
  29.  * Mark Hessling                     email: M.Hessling@itc.gu.edu.au
  30.  * 36 David Road                     Phone: +61 7 849 7731
  31.  * Holland Park                      Fax:   +61 7 875 7877
  32.  * QLD 4121
  33.  * Australia
  34.  */
  35. #include <stdlib.h>
  36. #include <stdio.h>
  37. void trace_initialise();
  38. void trace_function();
  39. void trace_return();
  40.  
  41. char trace_save_str[40];
  42. char trace_env[40];
  43. FILE *trace_fp;
  44. short trace_number,trace_level=(-1);
  45.  
  46. void trace_initialise()
  47. {
  48.  char *trace_env_ptr=getenv("TRACE");
  49.  
  50.  trace_fp = NULL;
  51.  if (trace_env_ptr == NULL)
  52.     return;
  53.  strcpy(trace_env,trace_env_ptr);
  54.  trace_number = trace_level = 0;
  55.  return;
  56. }
  57. void trace_function(trace_str)
  58. char *trace_str;
  59. {
  60.  
  61.  register int i;
  62.  if (trace_level == (-1))
  63.     return;
  64.  if (strcmp(trace_str,trace_save_str) == 0)
  65.    {
  66.     trace_number++;
  67.     trace_level++;
  68.     return;
  69.    }
  70.  trace_fp = fopen(trace_env,"a");
  71.  fprintf(trace_fp,"%5d\n",trace_number);
  72.  for (i=0;i<trace_level;i++)
  73.      fprintf(trace_fp,"  ");
  74.  fprintf(trace_fp,"(%d)%-s",trace_level,trace_str);
  75.  for (i=0;i<60-(trace_level*2)-strlen(trace_str);i++)
  76.      fprintf(trace_fp," ");
  77.  
  78.  trace_number = 1;
  79.  trace_level++;
  80.  fclose(trace_fp);
  81.  strcpy(trace_save_str,trace_str);
  82.  return;
  83. }
  84. void trace_return()
  85. {
  86.  if (trace_level == (-1))
  87.     return;
  88.  trace_level--;
  89.  if (trace_level < 0)
  90.     fprintf(trace_fp,"****** trace level below zero ********");
  91.  
  92.  return;
  93. }
  94.